package com.wf.provider;

import com.wf.entity.PageInfo;
import com.wf.entity.User;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * Created by yuzhongbo on 2017/5/3.
 */
@Component
@FeignClient("wf-power")
public interface UserProvider {

    //Operation(value="获取用户列表", notes="根据User获取用户列表")
    //ImplicitParam(name = "user", value = "User", required = false, dataType = "User")
    @LoadBalanced
    @RequestMapping(value = "/user")
    public PageInfo<User> getAllByPage(@ModelAttribute(value = "user") User user);

    //Operation(value="获取用户", notes="根据用户id获取用户")
    //ImplicitParam(name = "id", value = "用户id", required = true, dataType = "String")
    @LoadBalanced
    @RequestMapping(value = "/user/get/{id}")
    public User get(@PathVariable(value = "id") String id);

    //Operation(value="获取用户", notes="根据用户获取用户")
    //ImplicitParam(name = "user", value = "User", required = false, dataType = "User")
    @LoadBalanced
    @RequestMapping(value = "/user/selectOne")
    public User selectOne(@ModelAttribute(value = "user") User user);

    //Operation(value="删除用户", notes="根据用户id删除用户")
    //ImplicitParam(name = "id", value = "用户id", required = true, dataType = "String")
    @LoadBalanced
    @RequestMapping(value = "/user/delete/{id}")
    public ModelMap delete(@PathVariable(value = "id")  String id);

    //Operation(value="保存（添加/修改）用户", notes="根据User创建用户")
    //ImplicitParam(name = "user", value = "用户实体User", required = true, dataType = "User")
    @LoadBalanced
    @RequestMapping(value = "/user/save", method = RequestMethod.POST)
    public ModelMap save(@ModelAttribute(value = "user") User user);
}
